﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class AdminControl_OrderDesDetails : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        String _orderid = Request["orderid"];
        ShoppingDataContext spdt = new ShoppingDataContext();

        var ordernames = from p in spdt.PRO_BOOKEDs
                        select p.BookedID;
        if (ordernames.Count() > 0)
            this.orderID.Text = ordernames.First();
        else return;
       

        DataTable dataTable = new DataTable();
        dataTable.Columns.Add("imageurl");
        dataTable.Columns.Add("proname");
        dataTable.Columns.Add("size");
        dataTable.Columns.Add("color");
        dataTable.Columns.Add("number");
        dataTable.Columns.Add("price");
        dataTable.Columns.Add("sum");

        
        var ords = from p in spdt.PRO_BOOKED_DEs
                   join q in spdt.PRODUCT_DEs
                   on p.Product_DesID equals q.Product_DesID
                   join r in spdt.PRODUCTs
                   on q.ProductID equals r.ProductID
                   select new { q.image, r.ProName, q.Size, q.Color, q.price, p.amount };

        foreach (var ord in ords)
        {
            DataRow row = dataTable.NewRow();
            row["imageurl"] = ord.image;
            row["proname"] = ord.ProName;
            row["size"] = ord.Size;
            row["color"] = ord.Color;
            row["number"] = ord.amount;
            row["price"] = ord.price;
            row["sum"] = ord.price * ord.amount;
            dataTable.Rows.Add(row);
        }

        orderdesdetails.DataSource = dataTable;
        orderdesdetails.DataBind();
    }
}
